<?php

namespace App\Http\Controllers\Web;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Storage;

class UploadController extends Controller
{
    /**
     * 展示
     */
    public function index(){
        return view("test.upload");
    }

    /**
     * 图片保存
     */
    public function store(Request $request){

        $imgArr = [];
        if($request->hasFile("file")){
            $files = $request->file("file");
            if(is_array($files)){
                foreach($files as $file){
                    $path = Storage::disk("local")->put("images/file",$file);
                    $imgArr[] = $path;
                }
            }else{
                $path = Storage::disk("local")->put("images/file",$files);
                $imgArr[] = $path;
            }
        }

        dd($imgArr);
    }
}
